#include <limits>
#include <iostream>
#include <vector>
#include <string>
#include <cstdarg>
using namespace std;
int x;
void tesr1()
{
	enum flag {x=1,y=2,z=4,e=8};
	cout<<numeric_limits<float>::max()<<endl;
	cout<<numeric_limits<char>::is_signed<<endl;
	cout<<"int size"<<sizeof(int)<<endl;
	cout<<"float size "<<sizeof(float)<<endl;
	cout<<"long size  "<<sizeof(long)<<endl;
	cout<<"double size "<<sizeof(double)<<endl;
}
void test2()//the use of const point
{
	int i=9;
	int j=0;
	int *const pi = &i;
	*pi=10;
	cout<<*pi<<endl;
	cout<<i<<endl;
	//pi =&j;
	//cout<<*pi<<endl;
}
void test3()
{
	int x=2;
	{
		int x=3;
		//::x=4;//the x is a global variable
		cout<<x<<endl;
	}
	cout<<x<<endl;
	cout<<::x<<endl;
	double d;
	cout<<d<<endl;
}
void test4(const int *p)
{
//	*p =4;
}
void test5()
{
	int i=1;
	int rr = i;
	rr++;
	cout<<i<<endl;
}
struct Pair
{
	string name;
	double value;
};
vector<Pair>p;
void initp()
{
	Pair p1 = {"ZHUBICEN",100};
	Pair p2 = {"liuxinbao",99};
	Pair p3 = {"wangquanli",98};
	p.push_back(p1);
	p.push_back(p2);
	p.push_back(p3);
}
double &find(const string name)
{
	for(int i = 0;i<p.size();i++)
		if(name == p[i].name)
			return p[i].value;
	Pair s = {name,0};
	p.push_back(s);
	return p[p.size()-1].value;
}	
void Test6()
{
	
	initp();
	find("liuxinbao")=123;
	cout<<find("liuxinbao")<<endl;;
}
void  Test7()
{
	int i =100;
	void *pvoid = &i;
	double *p =static_cast<double*>(pvoid);
	cout<<*p<<endl;
}
class s;
void g(s temp);
struct Add
{
	char *name;
	long int num;
};
void Test8()
{
	//a
	Add a = {"JimDandy",999}; 	
	//b
	Add b;
	b.name = "WUJIA";
	b.num = 100;

	Add temp;
	temp = a;
	cout<<temp.name<<endl;
	temp.name = "ZHU";
	cout<<temp.name<<endl;

}
float &Test9()
{
	float a =1.00f;
	return a;//warning return a local var
}
void Test10(int i=0,int base =0);
void Test10(int i,int base )
{
	cout<<"The arg i : "<<i<<endl;
	cout<<"The base  : "<<base<<endl;
}
void Test11()
{
	Test10();
	Test10(100);
	Test10(200,200);
}

void error(int severity...)
{
	va_list ap;
	va_start(ap,severity);
	char *p = va_arg(ap,char*);
	cerr<<p<<' ';
	p = va_arg(ap,char*);
	cerr<<p<<' ';
	va_end(ap);
	cerr<<severity;
}
void Test12()//unhanled exception
{ 
	printf("The %s",2);
}
void main()
{
	error(1,"ZHUBICEN","HELLOWORLD");
}